package cn.tedu.springbootdemo.tedu;

import com.alibaba.druid.pool.DruidDataSource;

import java.sql.Connection;
import java.sql.SQLException;

public class Demo05 {
    public static void main(String[] args) throws SQLException {
        //创建连接池对象
        DruidDataSource yyds = new DruidDataSource();
        yyds.setUsername("root");
        yyds.setPassword("root");
        yyds.setUrl("jdbc:mysql://localhost:3306/empdb?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSl=false");
        //从连接池中获取数量  和最大连接对象
        yyds.setInitialSize(3);
        yyds.setMaxActive(5);
        //获取连接对象
        Connection conn = yyds.getConnection();
        System.out.println("连接对象" + conn);
    }

}
